package crm.view.Admin;

import crm.entity.Customer;
import crm.entity.Employee;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.util.List;
import java.util.Vector;

public class EmployeePerformance extends JFrame{

    public EmployeePerformance(List<Employee> list) {
        //如何由list来生成数据和表头
        Vector<Vector<Object>> vectordata=new Vector<>();

        for(Employee employee:list){
            Vector<Object> objs=new Vector<>();

            objs.add(employee.getPerformance());
            vectordata.add(objs);//objs是一条纪录对应的多个字段的vector列表
        }

        String[] labels={"业绩"};

        Vector<String> columnNames=new Vector<>();
        for(String label:labels){
            columnNames.add(label);
        }

        JTable table=new JTable(vectordata, columnNames);
        JScrollPane scrollPane = new JScrollPane(table);


        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
        JPanel panel = new JPanel();
        panel.setLayout(null);
        panel.setBorder(new TitledBorder(null, "查询员工业绩信息", TitledBorder.LEADING,
                TitledBorder.TOP, null, null));

        this.getContentPane().add(panel);

        panel.add(scrollPane);
        scrollPane.setBounds(15, 15, 500, 200);
        scrollPane.setBorder(new TitledBorder(null, "员工业绩信息",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        this.setSize(520, 400);

        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
}
